package com.jindy.module.associatedProductView.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.associatedProductView.domain.AssociatedProductView;
import com.jindy.module.associatedProductView.service.IAssociatedProductViewService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author jindy
 * @date 2023-06-06
 */
@RestController
@RequestMapping("/module/associatedProductView")
public class AssociatedProductViewController extends BaseController
{
    @Autowired
    private IAssociatedProductViewService associatedProductViewService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:associatedProductView:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssociatedProductView associatedProductView)
    {
        startPage();
        List<AssociatedProductView> list = associatedProductViewService.selectAssociatedProductViewList(associatedProductView);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:associatedProductView:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssociatedProductView associatedProductView)
    {
        List<AssociatedProductView> list = associatedProductViewService.selectAssociatedProductViewList(associatedProductView);
        ExcelUtil<AssociatedProductView> util = new ExcelUtil<AssociatedProductView>(AssociatedProductView.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:associatedProductView:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(associatedProductViewService.selectAssociatedProductViewById(id));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:associatedProductView:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssociatedProductView associatedProductView)
    {
        return toAjax(associatedProductViewService.insertAssociatedProductView(associatedProductView));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:associatedProductView:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssociatedProductView associatedProductView)
    {
        return toAjax(associatedProductViewService.updateAssociatedProductView(associatedProductView));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:associatedProductView:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(associatedProductViewService.deleteAssociatedProductViewByIds(ids));
    }
}
